<?php
/*
  $Id: ym_support.php $

  Copyright (c) 2011 Reynaldi Jansen;

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License v2 (1991)
  as published by the Free Software Foundation.
*/

class osC_Boxes_ym_support extends osC_Modules {
    var $_title,
        $_code = 'ym_support',
        $_author_name = 'ESC',
        $_author_www = 'http://esc.vn',
        $_group = 'boxes';

    function osC_Boxes_ym_support() {
        global $osC_Language;

        $this->_title = $osC_Language->get('box_ym_support_heading');
    }
 
    function initialize() {
        global $osC_Language, $osC_Database;

		$unames = explode(';', BOX_YM_SUPPORT_USERNAME);
        $titles = explode(';', BOX_YM_SUPPORT_TITLE);
        $type = BOX_YM_SUPPORT_TYPE;
        $this->_content = '';

		if (($type == "0") || ($type == "1") || ($type == "2") || ($type == "3") || ($type == "4") || ($type == "5")) {
			if (substr(BOX_YM_SUPPORT_USERNAME, -1, 1) == ';') {
				$this->_content .= '<table cellspacing="5" align="center">';
				for ($i = 0; $i < (count($unames) - 1); ++$i) {
					$this->_content .= '<tr>' .
									   '<td align="right">' . trim($titles[$i]) . '</td>' .
									   '<td>&nbsp;:&nbsp;</td>' .
									   '<td>' . '<a href="ymsgr:sendIM?' . trim($unames[$i]) . '">' .
									   '<img border=0 src="http://opi.yahoo.com/online?u=' . trim($unames[$i]) . '&m=g&t=' . $type . '" />' .
									   '</a></td>' .
									   '</tr>';
				}
				$this->_content .= '</table>';
			}
			else {
				$this->_content .= '<table align="center" cellspacing="5">';
				for ($i = 0; $i < count($unames); ++$i) {
					$this->_content .= '<tr>' .
									   '<td>' . trim($titles[$i]) . '</td>' .
									   '<td>&nbsp;:&nbsp;</td>' .
									   '<td>' . '<a href="ymsgr:sendIM?' . trim($unames[$i]) . '">' .
									   '<img border=0 src="http://opi.yahoo.com/online?u=' . trim($unames[$i]) . '&m=g&t=' . $type . '" />' .
									   '</a></td>' .
									   '</tr>';
				}
				$this->_content .= '</table>';
			}
		}
		
		else {
			$this->_content .= '<div style="text-align: center;">';
			if (substr(BOX_YM_SUPPORT_USERNAME, -1, 1) == ';') {
				for ($i = 0; $i < count($unames)-1; ++$i) {
					$this->_content .= '<span style="font-weight: bold; margin-top: 5px;">' . trim($titles[$i]) . '</span><br />' .
									   '<a href="ymsgr:sendIM?' . trim($unames[$i]) . '">' .
									   '<img border=0 src="http://opi.yahoo.com/online?u=' . trim($unames[$i]) . '&m=g&t=' . BOX_YM_SUPPORT_TYPE . '" />' .
									   '</a>' .
									   '<br /><br />';
				}
				$this->_content .= '</div>';
			}
			else {
				for ($i = 0; $i < count($unames); ++$i) {
					$this->_content .= '<span style="font-weight: bold; margin-top: 5px;">' . trim($titles[$i]) . '</span><br />' .
									   '<a href="ymsgr:sendIM?' . trim($unames[$i]) . '">' .
									   '<img border=0 src="http://opi.yahoo.com/online?u=' . trim($unames[$i]) . '&m=g&t=' . BOX_YM_SUPPORT_TYPE . '" />' .
									   '</a>' .
									   '<br /><br />';
				}
				$this->_content .= '</div>';
			}
		}
	}
 
    function install() {
        global $osC_Database;
 
        parent::install();
 
        $osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('YM Account Username', 'BOX_YM_SUPPORT_USERNAME', 'Username1;Username2;Username3', 'Username(s) (Separate with \";\")', '6', '0', now())");
        $osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Title Name', 'BOX_YM_SUPPORT_TITLE', 'Customer Service 1;Customer Service 2;Customer Service 3', 'Add title(s) of above each username (Separate with \";\")', '6', '0', now())");
        $osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('YM Icon Type', 'BOX_YM_SUPPORT_TYPE' , '14', 'Type of icon (0-24)', '6', '0', now())");
    }
 
    function getKeys() {
        if (!isset($this->_keys)) {
            $this->_keys = array('BOX_YM_SUPPORT_USERNAME', 'BOX_YM_SUPPORT_TITLE', 'BOX_YM_SUPPORT_TYPE');
        }
 
        return $this->_keys;
    }
}

?>